package  
{
	import Box2D.Collision.b2Manifold;
	import Box2D.Dynamics.b2ContactListener;
	import Box2D.Dynamics.Contacts.b2Contact;
	
	/**
	 * ...
	 * @author hbb
	 */
	public class MyContactListener extends b2ContactListener 
	{
		
		public function MyContactListener() 
		{
			
		}
		
		override public function BeginContact(contact:b2Contact):void 
		{
			var k:Number;
			
			if( ( contact.GetFixtureA().GetBody().GetUserData() == GameManager.Singleton.player
				&& contact.GetFixtureB().GetBody().GetUserData() is Block )
			||  ( contact.GetFixtureA().GetBody().GetUserData() is Block
				&& contact.GetFixtureB().GetBody().GetUserData() == GameManager.Singleton.player ) )
			{
				k = contact.GetManifold().m_localPlaneNormal.y / contact.GetManifold().m_localPlaneNormal.x;
				
				if ( 0 == k ) GameManager.Singleton.player.turnAround();
				else if ( k < 0 && k >-1 ) GameManager.Singleton.player.turnAround();
				else if ( k > 0 && k < 1 ) GameManager.Singleton.player.turnAround();
			}
		}
		
		override public function PreSolve(contact:b2Contact, oldManifold:b2Manifold):void 
		{
			
			/*
			if( ( contact.GetFixtureA().GetBody().GetUserData() == GameManager.Singleton.player
				&& contact.GetFixtureB().GetBody().GetUserData() is Ground )
			||  ( contact.GetFixtureA().GetBody().GetUserData() is Ground
				&& contact.GetFixtureB().GetBody().GetUserData() == GameManager.Singleton.player ) )
			{
			}
			*/
		}
		
	}

}